﻿using BasicInformation.Domain;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SCM.API.Read.Application.Command.Purchase;
using SCM.API.Read.Application.Command.Sale;
using SCM.Domain;
using SCM.ErrorCode;
using SCM.Extensions;

namespace SCM.API.Read.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
   
    public class SaleController : ControllerBase
    {
        IMediator mediator;

        public SaleController(IMediator mediator)
        {
            this.mediator = mediator;
        }
       
        [HttpGet]
        public async Task<APIResult<SaleManagementModel>> GetSale([FromQuery]GetSaleCommand request)
        {
            return await mediator.Send(request);
        }
        [HttpGet]
        public Task<APIResult<ClientModel>> GetClient([FromQuery]GetClientCommand request)
        {
            return  mediator.Send(request);
        }
        [HttpGet]
        public async Task<APIResult<SaleProductDTO>> GetSaleProduct([FromQuery]GetProductCommand request)
        {
            return await mediator.Send(request); 
        }
        [HttpGet]
        public Task<APIResult<SaleManagementModel>> FanSale([FromQuery]FanSaleCommand request)
        {
            return  mediator.Send(request);
        }
        [HttpGet]
        public async Task<APIResult<SaleManagementModel>> GetSaleOne([FromQuery]GetSaleOneCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
